package com.task.controller.factory;

import com.task.controller.manager.impl.ParamParserManager;
import com.task.controller.param.ParamParser;

public class ParserFactory {

    public static ParamParser getParser(Class<? extends ParamParser> cls) {
        ParamParser paramParser = ParamParserManager.getInstance().lookup(cls);
        if (paramParser == null) {
            try {
                paramParser = cls.newInstance();
                ParamParserManager.getInstance().register(cls, paramParser);
            } catch (IllegalAccessException | InstantiationException e) {
                e.printStackTrace();
            }
        }
        return paramParser;
    }
}
